package net.huashitong.ssydt.provider.pk.service;

import net.huashitong.ssydt.base.dao.LongMapper;
import net.huashitong.ssydt.base.service.AbstractLongService;
import net.huashitong.ssydt.pk.entity.SsPkYzddQuestionRecord;
import net.huashitong.ssydt.provider.pk.mapper.SsPkYzddQuestionRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author <a href="mailto:yhy23456@163.com">huiyang.yu</a>
 * @since 2017.12.18
 */
@Service
@Transactional
public class SsPkYzddQuestionRecordServiceImpl extends AbstractLongService<SsPkYzddQuestionRecord> implements SsPkYzddQuestionRecordService {

    private SsPkYzddQuestionRecordMapper mapper;

    @Autowired
    public SsPkYzddQuestionRecordServiceImpl(SsPkYzddQuestionRecordMapper mapper) {
        this.mapper = mapper;
    }

    @Override
    protected LongMapper<SsPkYzddQuestionRecord> getLongMapper() {
        return this.mapper;
    }

    @Override
    public List<SsPkYzddQuestionRecord> findByRecordIdWithLoadNumberWithUserId(Long recordId, Integer loadNumber, String userId) {
        SsPkYzddQuestionRecord record = new SsPkYzddQuestionRecord();
        record.setChallengeRecordId(recordId);
        record.setLoadNumber(loadNumber);
        record.setUserId(userId);
        return this.mapper.findByRecordIdWithLoadNumberWithUserId(record);
    }

    @Override
    public List<SsPkYzddQuestionRecord> findByRecordIdWithUserId(Long recordId, String userId) {
        SsPkYzddQuestionRecord record = new SsPkYzddQuestionRecord();
        record.setChallengeRecordId(recordId);
        record.setUserId(userId);
        return this.mapper.findByRecordIdWithUserId(record);
    }

    @Override
    public int batchInsert(List<SsPkYzddQuestionRecord> ssPkYzddQuestionRecords) {
        return this.mapper.batchInsert(ssPkYzddQuestionRecords);
    }
}
